﻿using System;
using System.ComponentModel;

namespace YArchitech.Controls
{
	[TypeConverter(typeof(MostValueConverter))]
	[RefreshProperties(RefreshProperties.All)]
	public class MostValue
	{
		public MostValue()
		{
			this.minimal = 0.0;
			this.maximum = 0.0;
		}

		public MostValue(double min, double max)
		{
			this.minimal = min;
			this.maximum = max;
		}

		public double Minimal
		{
			get
			{
				return this.minimal;
			}
			set
			{
				this.minimal = value;
			}
		}

		public double Maximum
		{
			get
			{
				return this.maximum;
			}
			set
			{
				this.maximum = value;
			}
		}

		public bool Test(double value)
		{
			return this.Minimal > this.Maximum || (Math.Abs(this.Maximum - this.Minimal) < 1E-09 && Math.Abs(this.Maximum) < 1E-09) || (value >= this.minimal && value <= this.Maximum);
		}

		private double minimal;

		private double maximum;
	}
}
